<script setup lang="ts">
import { ref } from 'vue';
import { getCircleData } from '@/api/Assist';

// 声明emits以避免Vue 3警告
defineEmits(['postMessage']);

const paramsFaMen = {
  lat: 36.66492661698387,
  lon: 117.02426045812123,
  radius: 3000,
  serCode: '10001'
};
const paramsTiaoYaQi = {
  lat: 36.66492661698387,
  lon: 117.02426045812123,
  radius: 3000,
  serCode: '10002'
};
const Regulator = ref({
  content: [],
  setVo: {
    name: ''
  }
});
const valve = ref({
  content: [],
  setVo: {
    name: ''
  }
});
/**
 * 获取阀门 调压器数量
 */
//获取调压器阀门数据
const getCircleDataHandler = async (params) => {
  const { data } = await getCircleData(params);
  if (data[0].setVo.code == '10002') {
    //代表是调压箱
    Regulator.value = data[0];
  } else {
    valve.value = data[0];
  }
};
onMounted(async () => {
  await getCircleDataHandler(paramsFaMen);
  await getCircleDataHandler(paramsTiaoYaQi);
});
</script>

<template>
  <el-row :gutter="20" class="site-box">
    <el-col :span="12">
      <div class="site-item-box">
        <div class="site-item-icon-box">{{ Regulator?.content.length }}</div>
        <div class="site-item-text-box">{{ Regulator?.setVo.name }}</div>
      </div>
    </el-col>
    <el-col :span="12">
      <div class="site-item-box">
        <div class="site-item-icon-box">{{ valve?.content.length }}</div>
        <div class="site-item-text-box">{{ valve?.setVo.name }}</div>
      </div>
    </el-col>
  </el-row>
</template>

<style scoped lang="scss">
.site-box {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.site-item-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.1rem; // 添加一些内边距
  color: white;

  .site-item-icon-box {
    width: 7.25rem;
    height: 5.6056rem;
    text-align: center;
    line-height: 1.875rem;
    background: url(@/assets/largescreen/station-mag-icon.png) no-repeat center center;
    background-size: 100% 100%;
    font-size: 1.25rem;
    font-family: YouSheYaHei;
    font-weight: 700;
    cursor: pointer;
  }

  .site-item-text-box {
    margin-top: 0.1rem;
  }
}
</style>
